Skip to content
BooLeet  /   Dungeon-Warrior  /  
Clear Command Palette
Tip: Type # to search pull requests
Type ? for help and tips
Tip: Type # to search issues
Type ? for help and tips
Tip: Type # to search discussions
Type ? for help and tips
Tip: Type ! to search projects
Type ? for help and tips
Tip: Type @ to search teams
Type ? for help and tips
Tip: Type @ to search people and organizations
Type ? for help and tips
Tip: Type > to activate command mode
Type ? for help and tips
Tip: Go to your accessibility settings to change your keyboard shortcuts
Type ? for help and tips
Tip: Type author:@me to search your content
Type ? for help and tips
Tip: Type is:pr to filter to pull requests
Type ? for help and tips
Tip: Type is:issue to filter to issues
Type ? for help and tips
Tip: Type is:project to filter to projects
Type ? for help and tips
Tip: Type is:open to filter to open content
Type ? for help and tips
We’ve encountered an error and some results aren't available at this time. Type a new search or try again later.
No results matched your search
Search for issues and pull requests # Search for issues, pull requests, discussions, and projects # Search for organizations, repositories, and users @ Search for projects ! Search for files / Activate command mode > Search your issues, pull requests, and discussions # author:@me Search your issues, pull requests, and discussions # author:@me Filter to pull requests # is:pr Filter to issues # is:issue Filter to discussions # is:discussion Filter to projects # is:project Filter to open issues, pull requests, and discussions # is:open
  • Watch 1

    Notifications

    Get push notifications on iOS or Android.
Permalink
Browse files
First massive gameplay update
+ Enemy stun state and animations.
+ Force push with auto aim on DeadlyObjects
(e.g. ExplosiveBarrel, Spikes).
+ Force pull for enemies and interacting with distant objects (extends the interaction mechanic).
+ Enemy destruction.
+ Revolver attack.
+ Magica bar.
+ Fix to AI alarm system
+ Attack token differentiation (GruntMelee, GruntRange, HeavyMelee ,HeavyRange)

+ Main menu
+ Graphics, audio and game settings.
  • Loading branch information
BooLeet committed Aug 2, 2020
1 parent 5141e6a commit e8f6c311ab330a765c12d6d97dd798afaa5bbc14
Show file tree
Hide file tree
Showing 2,712 changed files with 804,926 additions and 848 deletions.
@@ -11,10 +11,14 @@ public class AICharacter : Character {
public bool IsAlert { get; private set; }
public bool CanAttack { get; private set; }
public bool IsStunned { get; private set; }

private float stunCurrentTime;
public bool StickToSurfaceOnDeath { get; set; }
public bool IsWalking { get; set; }

public AICharacterAnimator characterAnimator;
public Pullable pullableBehaviour;
private Entity lastDamageGiver;
public Entity stunGiver { get; private set; }

private AIDirector director;
private Character currentEnemy;
@@ -35,6 +39,34 @@ public class AICharacter : Character {
private Vector2 rapidMovementVector;
private Vector2 targetRapidMovementVector;

protected override void ControllerStart()
{
currentState = new PatrolState();
director = AIDirector.GetInstance();
director.Register(this);

StartCoroutine(RapidMovementVectorGeneration());
}

protected override void ControllerUpdate()
{
if (!IsDead)
{
AttackTokenCooldownUpdate();
UpdateCurrentEnemy();
PropertiesUpdate();
RapidMovementVectorSmoothing();
StunUpdate();
StateMachine();

if (canAttack)
characterAnimator.WalkingAnimation(IsWalking && canAttack && IsNearGround());

Gravity();
ApplyMovement();
}
}

#region AI functions
private void StateMachine()
{
@@ -62,7 +94,10 @@ private void PropertiesUpdate()

if (currentEnemy)
{
EnemyIsVisible = Utility.IsVisible(head.position, currentEnemy.gameObject, aiStats.visibilityDistance, currentEnemy.verticalTargetingOffset);
int layerMask = 1 << gameObject.layer;
layerMask = ~layerMask;
EnemyIsVisible = Utility.WithinAngle(head.position,head.forward, currentEnemy.gameObject.transform.position + Vector3.up * currentEnemy.verticalTargetingOffset,aiStats.visibilityAngle)
&& Utility.IsVisible(head.position, currentEnemy.gameObject, aiStats.visibilityDistance, currentEnemy.verticalTargetingOffset, layerMask);
DistanceToEnemy = Vector3.Distance(Position, currentEnemy.Position);
}

@@ -75,7 +110,8 @@ private void UpdateCurrentEnemy()
var closestVisibleEnemyCharacters = from entity in EntityRegistry.GetInstance().GetClosestEntities(Position, aiStats.visibilityDistance, this)
where entity as Character &&
(entity as Character).stats.alliance != stats.alliance &&
Utility.IsVisible(head.position, entity.gameObject, aiStats.visibilityDistance, entity.verticalTargetingOffset)
Utility.IsVisible(head.position, entity.gameObject, aiStats.visibilityDistance, entity.verticalTargetingOffset) &&
Utility.WithinAngle(head.position, head.forward, entity.gameObject.transform.position + Vector3.up * entity.verticalTargetingOffset, aiStats.visibilityAngle)
select new { character = entity as Character, distance = Vector3.Distance(Position, entity.Position) };

if (closestVisibleEnemyCharacters.Count() == 0)
@@ -134,11 +170,14 @@ private IEnumerator AttackRoutine()
canAttack = false;
characterAnimator.Attack();
yield return new WaitForSeconds(characterAnimator.attackAnimation.attackDamageDelay);
if (!IsStunned)
{
aiStats.attackFunction.DoAttackDamage(this, aiStats.attackDamage);

aiStats.attackFunction.DoAttackDamage(this, aiStats.attackDamage);

yield return new WaitForSeconds(characterAnimator.attackAnimation.attackDuration - characterAnimator.attackAnimation.attackDamageDelay);
canAttack = true;
yield return new WaitForSeconds(characterAnimator.attackAnimation.attackDuration - characterAnimator.attackAnimation.attackDamageDelay);
canAttack = true;
}

}

// Makes character to do an attack and starts the attack token cooldown
@@ -148,6 +187,9 @@ public void AIAttack()
Attack();
}

#endregion

#region Attack Tokens
private void AttackTokenCooldownUpdate()
{
if (attackTokenCooldown > 0)
@@ -188,6 +230,9 @@ private void SpendAttackToken()

}

#endregion

#region Rapid Movement
private void RapidMovementVectorSmoothing()
{
rapidMovementVector = Vector2.Lerp(rapidMovementVector, targetRapidMovementVector, Time.deltaTime * 5);
@@ -209,56 +254,92 @@ public void RapidMovement()

#endregion

#region Overrides
public override Vector3 GetAttackDirection(float spreadAngleDeg)
{
Vector3 insideUnitSphere = Random.insideUnitSphere * spreadAngleDeg / 90;
#region Stun

return insideUnitSphere + (currentEnemy ? (currentEnemy.Position - characterAnimator.attackAnimation.damageSource.position).normalized : transform.forward);
public void Stun(float duration, Entity stunGiver)
{
//if (IsStunned)
// return;
this.stunGiver = stunGiver;
stunCurrentTime = Mathf.Max(stunCurrentTime, duration);
//StartCoroutine(StunRoutine(duration));
}

public override Vector3 GetAttackSource()
private void StunUpdate()
{
return characterAnimator.attackAnimation.damageSource.position;
if(stunCurrentTime > 0)
{
if(!IsStunned)
characterAnimator.PlayStunStartAnimation();
IsStunned = true;
canAttack = false;
stunCurrentTime -= Time.deltaTime;
}
else
{
stunCurrentTime = 0;
if(IsStunned)
StartCoroutine(StunRecoveryRoutine());
}

}

protected override void ControllerStart()
private IEnumerator StunRecoveryRoutine()
{
currentState = new PatrolState();
director = AIDirector.GetInstance();
director.Register(this);
characterAnimator.PlayStunEndAnimation();
yield return new WaitForSeconds(characterAnimator.stunEndDuration);
canAttack = true;
IsStunned = false;
}

StartCoroutine(RapidMovementVectorGeneration());
private IEnumerator StunRoutine(float duration)
{
IsStunned = true;
canAttack = false;
characterAnimator.PlayStunStartAnimation();
yield return new WaitForSeconds(duration + characterAnimator.stunStartDuration);
characterAnimator.PlayStunEndAnimation();
yield return new WaitForSeconds(characterAnimator.stunEndDuration);
canAttack = true;
IsStunned = false;
}

protected override void ControllerUpdate()
#endregion

#region Overrides


public override Vector3 GetAttackDirection(float spreadAngleDeg)
{
if (!IsDead)
{
AttackTokenCooldownUpdate();
UpdateCurrentEnemy();
PropertiesUpdate();
RapidMovementVectorSmoothing();
StateMachine();
Vector3 insideUnitSphere = Random.insideUnitSphere * spreadAngleDeg / 90;

if(canAttack)
characterAnimator.WalkingAnimation(IsWalking && canAttack && IsNearGround());
return insideUnitSphere + (currentEnemy ? (currentEnemy.Position - characterAnimator.attackAnimation.damageSource.position).normalized : transform.forward);
}

Gravity();
ApplyMovement();
}
public override Vector3 GetAttackSource()
{
return characterAnimator.attackAnimation.damageSource.position;
}



protected override void DeathEffect()
{
if (HasAttackToken)
director.ReturnAttackToken();
director.Unregister(this);
if(pullableBehaviour)
pullableBehaviour.Unregister();
Destroy(controller);
characterAnimator.DeathEffect(lastDamageGiver ? Position + 4 * (lastDamageGiver.Position - Position).normalized : Position, StickToSurfaceOnDeath);
Destroy(gameObject);
}

protected override void OnDamageTaken(float rawDamage, Entity damageGiver, Vector3 sourcePosition)
{
characterAnimator.PlayDamageEffect();
lastDamageGiver = damageGiver;

if (currentEnemy == null && damageGiver as Character)
Alarm(damageGiver as Character);
}
@@ -6,6 +6,26 @@ public class AICharacterAnimator : CharacterAnimator
{
public AttackAnimationInfo attackAnimation;
private int attackTriggerIndex = 0;
[Space]
public string stunStartTrigger = "StunStart";
public float stunStartDuration;
public string stunEndTrigger = "StunEnd";
public float stunEndDuration;
[Header("Model Destruction")]
public DestructableObject destructableObject;
public float explosionForce = 1000;
public float explosionRadius = 5;

public void PlayStunStartAnimation()
{
animator.SetTrigger(stunStartTrigger);
animator.ResetTrigger(stunEndTrigger);
}

public void PlayStunEndAnimation()
{
animator.SetTrigger(stunEndTrigger);
}

public void Attack()
{
@@ -17,4 +37,9 @@ public void PlayAttackSound()
{
PlayAttackSound(attackAnimation);
}

public void DeathEffect(Vector3 explosionPosition,bool sticky)
{
destructableObject.Destruct(explosionForce, explosionPosition, explosionRadius, sticky);
}
}
@@ -35,11 +35,8 @@ public class AlertState : AI_FSM_State
{
public override void Action(AICharacter character)
{
if (character.EnemyIsVisible)
{
character.LookAtEnemy();
character.RapidMovement();
}
character.LookAtEnemy();
character.RapidMovement();
}

public override void Init(AICharacter character)
@@ -167,12 +164,12 @@ public override void Action(AICharacter character)

public override void Init(AICharacter character)
{
// Start stun animation

}

public override AI_FSM_State Transition(AICharacter character)
{
if (character.IsStunned)
if (!character.IsStunned)
return new AlertState();
return null;
}
@@ -9,13 +9,13 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 930b82cf2a69819498c2c5f11cd9711b, type: 3}
m_Name: RangeEnemyStats
m_Name: CorruptedSkeletonStats
m_EditorClassIdentifier:
attackFunction: {fileID: 11400000, guid: 017d44edd3380ce4abcecb923986bdf5, type: 2}
attackDamage: 1.5
attackDamage: 8
visibilityDistance: 100
attackDistance: 40
rapidMovementSpeed: 5
rapidMovementSpeed: 0
visibilityAngle: 90
attackTokenCooldownTime: 5
attacksPerToken: 5
@@ -0,0 +1,21 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 930b82cf2a69819498c2c5f11cd9711b, type: 3}
m_Name: DemonKnightStats
m_EditorClassIdentifier:
attackFunction: {fileID: 11400000, guid: 898745e5aace9344781e64e363c646b0, type: 2}
attackDamage: 40
visibilityDistance: 100
attackDistance: 5
rapidMovementSpeed: 0.5
visibilityAngle: 90
attackTokenCooldownTime: 2
attacksPerToken: 1

Some generated files are not rendered by default. Learn more.

@@ -9,12 +9,12 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 930b82cf2a69819498c2c5f11cd9711b, type: 3}
m_Name: MeleeEnemyStats
m_Name: DemonSoldierStats
m_EditorClassIdentifier:
attackFunction: {fileID: 11400000, guid: f2e73306a42c9ee42b1ac5e7bc39584e, type: 2}
attackDamage: 15
attackDamage: 25
visibilityDistance: 100
attackDistance: 4
attackDistance: 2.75
rapidMovementSpeed: 0.5
visibilityAngle: 90
attackTokenCooldownTime: 2
@@ -9,18 +9,18 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9fdbad2fbce79da4fbd248c9fd51823e, type: 3}
m_Name: EnemyRange
m_Name: CorSkelProjectile
m_EditorClassIdentifier:
numberOfProjectiles: 4
numberOfProjectiles: 1
spreadAngle: 15
info:
name: Projectile
radius: 0.1
speed: 200
speed: 40
lifeTime: 1
maxPenetrations: 0
onHit:
onHitFunctors: []
model: {fileID: 1304658746372660, guid: bb98a131d637f9241a8726846f558e68, type: 2}
model: {fileID: 1664740601458906, guid: 708775beb71ae9b4d8beef56ace29502, type: 2}
hitEffect: {fileID: 1706171305083330, guid: 7e3155a23b72bf544b1bff76ff88d9b1,
type: 2}
@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2e078e6490701c540add3cdbbe58df60, type: 3}
m_Name: DemKnightMelee
m_EditorClassIdentifier:
enemiesPerHit: 4
attackRange: 6
angle: 90

0 comments on commit e8f6c31

@OhardProductiona
Add heading text Add bold text, <Ctrl+b> Add italic text, <Ctrl+i>
Add a quote, <Ctrl+Shift+.> Add code, <Ctrl+e> Add a link, <Ctrl+k>
Add a bulleted list, <Ctrl+Shift+8> Add a numbered list, <Ctrl+Shift+7> Add a task list, <Ctrl+Shift+l>
Directly mention a user or team Reference an issue, pull request, or discussion
Select a reply ctrl .
Add saved reply
Add heading text Add bold text, <Ctrl+b> Add italic text, <Ctrl+i> Add a bulleted list, <Ctrl+Shift+8> Add a numbered list, <Ctrl+Shift+7> Add a task list, <Ctrl+Shift+l>

You’re not receiving notifications from this thread.